package jrobutt.room.level;

import jrobutt.*;

import java.awt.Graphics2D;
import java.awt.Dimension;
import java.awt.Point;

public class GuyCamera implements Renderable
{
    public int width;
    public int height;
    
    public Guy subject;
    public float level_width;
    public float level_height;
    
    private Point get_location ()
    {
        float x = subject.x - width/2;
        float y = subject.y - height/2;
        x = Math.min(Math.max(0.0f, x), level_width - width);
        y = Math.min(Math.max(0.0f, y), level_height - height);
        return new Point((int)x, (int)y);
    }
    
    public GuyCamera (Dimension screen_size, Guy subject, TerrainGrid terrain)
    {
        this.subject = subject;
        this.width = screen_size.width;
        this.height = screen_size.height;
        
        this.level_width = terrain.scale * terrain.width;
        this.level_height = terrain.scale * terrain.height;
    }
    
    public void render (Graphics2D g)
    {
        Point p = get_location();
        g.translate(-p.x, -p.y);
    }
}
